from PyQt5.QtWidgets import *
from PyQt5 import QtGui
import sys
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import time
import pymysql

import database.admin.setting as setting
import interface.student.course_comment as course_comment
class course_comment_window(QMainWindow,course_comment.Ui_Form):###点击用户身份弹出的登陆小弹窗
    def __init__(self,cid,sid):
        QMainWindow.__init__(self)
        course_comment.Ui_Form.__init__(self)
        self.setupUi(self)
        self.sid=sid
        self.cid=cid
        self.setWindowTitle("课程评价")
        self.s1.setMinimum(1)
        self.s1.setMaximum(10)
        self.s1.setTickPosition(QSlider.TicksBelow)
        self.s1.setTickInterval(1)
        self.s2.setMinimum(1)
        self.s2.setMaximum(10)
        self.s2.setTickInterval(1)
        self.s2.setTickPosition(QSlider.TicksBelow)
        self.s1.valueChanged.connect(self.s1v)
        self.s2.valueChanged.connect(self.s2v)
        self.cancel.clicked.connect(self.close)
        self.ok.clicked.connect(self.commit)
        self.init_window()
    def init_window(self):
        self.connect = pymysql.connect(**setting.config)
        self.cursor = self.connect.cursor()
        sql_="select cname,tname from course where id=%s"
        self.cursor.execute(sql_,self.cid)
        re=self.cursor.fetchone()
        self.course=re[0]
        self.teacher=re[1]
        self.c.setText(self.course)
        self.t.setText(self.teacher)
        self.cursor.close()
        self.connect.close()
    def commit(self):
        pass
    def s1v(self):
        s1_value=self.s1.value()
        self.s1_v.setText(str(s1_value)+'分')
    def s2v(self):
        s2_value = self.s2.value()
        self.s2_v.setText(str(s2_value)+'分')
if __name__=='__main__':
    app=QApplication(sys.argv)
    md=course_comment_window("00001","2018300354")
    md.show()
    sys.exit(app.exec_())